; tvscanner.1.0.2.3.INSTALLER.nsi
; mod: 14-01-2009
;--------------------------------

; The name of the installer
Name "TVScanner 2009 Version 1.0.2.3"

; The file to write (installer file)
OutFile "TVScanner 1.0.2.3 (install).exe"

; The default installation directory
InstallDir $PROGRAMFILES\TVScanner

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\TVScanner "TVScanner"

; The text to prompt the user to enter a directory
ComponentText "Installation directory."

; The text to prompt the user to enter a directory
DirText "Installation directory:"

;--------------------------------

; The stuff to install
Section "TVScanner (needed)"

SectionIn RO

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; Terminate
  KillProcDLL::KillProc "TVScanner.exe"
  
  ; Put file there
  File "TVScanner.exe"
  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\TVScanner "TVScanner" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TVScanner" "TVScanner" "TVScanner (delete only)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TVScanner" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteUninstaller "uninstall.exe"

  ; start
  Exec "$INSTDIR\TVScanner.exe"
  
SectionEnd

; optional section (can be disabled by the user)

Section "Shortcuts"

  CreateShortCut "$DESKTOP\TVScanner.lnk" "$INSTDIR\TVScanner.exe" ""

  CreateDirectory "$SMPROGRAMS\TVScanner"
  CreateShortCut "$SMPROGRAMS\TVScanner\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\TVScanner\TVScanner.lnk" "$INSTDIR\TVScanner.exe" "" "$INSTDIR\TVScanner.exe" 0

  
SectionEnd


;--------------------------------

; Uninstaller

UninstallText "TVScanner uninstall"

; Uninstall section

Section "Uninstall"

  ; remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TVScanner"
  DeleteRegKey HKLM SOFTWARE\TVScanner

  ; terminate
  KillProcDLL::KillProc "TVScanner.exe"

  ; remove files and uninstaller
  Delete $INSTDIR\TVScanner.exe
  Delete $INSTDIR\uninstall.exe

  ; remove shortcuts, if any
  Delete "$SMPROGRAMS\TVScanner\*.*"

  ; remove directories used
  RMDir "$SMPROGRAMS\TVScanner"
  RMDir "$INSTDIR"

SectionEnd
